package com.qianxp.designparttern.template;

import java.lang.reflect.Field;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

/**
 * @author qianxp
 * @createTime 2019/11/17 0017
 */
public class TestCJdbcTemplate {
    private static CJdbcTemplate cJdbcTemplate = new CJdbcTemplate(null);

    public static void main(String[] args) throws Exception {
        String sql = "select * from t_member where username = ? and nickname = ?";
        cJdbcTemplate.executeQuery(sql, new RowMapper<Member>() {
            @Override
            Member processResult(ResultSet rs) throws Exception {
                Member member = new Member();
                Field[] fileds = Member.class.getDeclaredFields();
                for(Field field : fileds){
                    field.set(member,rs.getString(field.getName()));
                }
                return member;
            }
        },new Object[]{"小明","爱豆"});
    }
}
